<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单控件的焦点</title>
    <script src="../../js/jquery-1.4.2.js"></script>
</head>
<body>
    <input type="text" name="username"
           onblur="blurFu(this)" onfocus="focusFu(this)">
</body>
<script>
    //失去焦点
    function blurFu(thisObj){
        if (thisObj.value==''){
            thisObj.value='请输入用户名'
        }
    }
    //获取焦点
    function focusFu(thisObj){
        if (thisObj.value=='请输入用户名'){
            thisObj.value=''
        }
    }
</script>
</html>